//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "SolnLun" //자료실 컴포넌트.. 양/음력 변환 #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormShow(TObject *Sender) { HolyListBox = new TListBox(Form1); LunarHolyListBox = new TListBox(Form1); LunarRelayHolyListBox = new TListBox(Form1); HolyListBox->Parent = Form1; LunarHolyListBox->Parent = Form1; LunarRelayHolyListBox->Parent = Form1; HolyListBox->Visible = false; LunarHolyListBox->Visible = false; LunarRelayHolyListBox->Visible = false; AnsiString NowYear = Now().FormatString("YYYY"); AnsiString CalYear = ""; TDateTime TempDateTime; for(int i=-1; i <= 1; i++ ) // 올해 기준 +/- 1 year 추가 양/음 변환시 년도 바뀜 { CalYear = IntToStr(StrToInt(NowYear) + i); HolyListBox->Items->Add(CalYear + "-03-01"); HolyListBox->Items->Add(CalYear + "-10-03"); HolyListBox->Items->Add(CalYear + "-08-15"); HolyListBox->Items->Add(CalYear + "-12-25"); HolyListBox->Items->Add(CalYear + "-01-01"); HolyListBox->Items->Add(CalYear + "-05-05"); HolyListBox->Items->Add(CalYear + "-06-06"); LunarHolyListBox->Items->Add(CalYear + "-04-08"); // 바로 양력 변환 LunarRelayHolyListBox->Items->Add(CalYear + "-01-01"); // 양력 변환 -> +/- 1일 도 추가 LunarRelayHolyListBox->Items->Add(CalYear + "-05-15"); // 상동 } for(int i=0; i <= LunarHolyListBox->Items->Count-1; i++) { SL->lunYear = StrToInt(LunarHolyListBox->Items->Strings[i].SubString(1,4)); SL->lunMonth = StrToInt(LunarHolyListBox->Items->Strings[i].SubString(6,2)); SL->lunDay = StrToInt(LunarHolyListBox->Items->Strings[i].SubString(9,2)); SL->Lunar2Solar(); HolyListBox->Items->Add(IntToStr(SL->solYear)+"-"+Fix2Str(IntToStr(SL->solMonth))+"-"+Fix2Str(IntToStr(SL->solDay))); } for(int i=0; i <= LunarRelayHolyListBox->Items->Count-1; i++) { SL->lunYear = StrToInt(LunarRelayHolyListBox->Items->Strings[i].SubString(1,4)); SL->lunMonth = StrToInt(LunarRelayHolyListBox->Items->Strings[i].SubString(6,2)); SL->lunDay = StrToInt(LunarRelayHolyListBox->Items->Strings[i].SubString(9,2)); SL->Lunar2Solar(); TempDateTime = StrToDateTime(IntToStr(SL->solYear)+"-"+Fix2Str(IntToStr(SL->solMonth))+"-"+Fix2Str(IntToStr(SL->solDay))+" 00:00:00"); for(int i =-1; i <=1; i++) { HolyListBox->Items->Add( IncDay(TempDateTime,i).FormatString("YYYY-MM-DD") ); } } MaskEdit1->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TForm1::MaskEdit1Change(TObject *Sender) { AnsiString TempDateTime = StringReplace(StringReplace(MaskEdit1->Text, "-", "", TReplaceFlags()<Text = GetFinishPlanDate(MaskEdit1->Text); } } //--------------------------------------------------------------------------- AnsiString __fastcall TForm1::GetFinishPlanDate(AnsiString str_NowDateTime) { TDateTime NowDateTime; TDateTime FinishDateTime; int UseDateCount = 1; int ListSameCount = 0; int RealDateCount = 0; NowDateTime = StrToDateTime(str_NowDateTime); for(UseDateCount =1; UseDateCount <= 10; UseDateCount++) { if( IncHour(NowDateTime, (UseDateCount*24)).FormatString("DDD") == "토" || IncHour(NowDateTime, (UseDateCount*24)).FormatString("DDD") == "일" ) { //ShowMessage(IncHour(NowDateTime, (UseDateCount*24)).FormatString("DDD")); }else { ListSameCount = 0; for(int index =0; index <= HolyListBox->Items->Count-1; index++) { if( IncHour(NowDateTime, (UseDateCount*24)).FormatString("YYYY-MM-DD") == HolyListBox->Items->Strings[index] ) { ListSameCount++; } } if(ListSameCount == 0) { RealDateCount++; } if(RealDateCount == 3) { FinishDateTime = IncDay(NowDateTime,UseDateCount); return FinishDateTime.FormatString("YYYY-MM-DD HH:NN:SS"); } } } } //--------------------------------------------------------------------------- void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) { delete HolyListBox; delete LunarHolyListBox; delete LunarRelayHolyListBox; } //--------------------------------------------------------------------------- AnsiString __fastcall TForm1::Fix2Str(AnsiString TempStr) { if(TempStr.Length() == 1 ) { TempStr = "0"+TempStr; } return TempStr; } //---------------------------------------------------------------------------